package com.woniuxy02;

import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-07-16 14:26
 */
public class Test14 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //产生一个随机数
        int random = (int) (Math.random() * 100);
        System.out.println("random:" + random);
        int num;
        //flag--true猜对了
        boolean flag = false;
        for (int i = 1; i <= 3; i++) {
            System.out.println("输入你猜的数字");
            num = sc.nextInt();
            if (num > random) {
                System.out.println("猜大了");
            } else if (num < random) {
                System.out.println("猜小了");
            } else {
                flag = true;
                break;
            }
        }

        //下结论
        if (flag) {
            System.out.println("游戏结束，猜数字成功");
        } else {
            System.out.println("游戏结束，猜数字失败");
        }


    }
}
